/**
 * Copyright (c) 快宝网络 kuaidihelp.com Co., Ltd. All Rights Reserved 禁止外泄以及用于其它的商业用途
 */

import { Request, Response } from 'express';
import { ResponseItem, responseSuccess } from '../utils';
import Mock, { mock } from 'mockjs';

export default {
  'POST /jdk/Brand/getDelivery': (req: Request, res: Response) => {
    const list = [
      {
        code: 'sftc',
        name: '顺丰同城',
      },
      {
        code: 'ddks',
        name: '达达',
      },
      {
        code: 'fnpt"',
        name: '蜂鸟',
      },
      {
        code: 'sto',
        name: '申通',
      },
    ];
    const result: ResponseItem = {
      code: 0,
      msg: '成功',
      data: list,
    };
    return res.json(result);
  },
  'POST /jdk/Brand/getSource': (req: Request, res: Response) => {
    const list = [
      {
        code: 'meituan',
        name: '美团',
      },
      {
        code: 'elm',
        name: '饿了吗',
      },
      {
        code: 'dylk"',
        name: '抖音来客',
      },
    ];
    const result: ResponseItem = {
      code: 0,
      msg: '成功',
      data: list,
    };
    return res.json(result);
  },
  'POST /jdk/delivery/Forbid/getList': (req: Request, res: Response) => {
    const data = Mock.mock({
      'list|1-30': [
        {
          brand_name: '顺丰同城',
          brand: 'sftc',
          'type|1': [3, 0],
          'shieldType|1': [1, 2],
          area_name_list: [
            ['上海市', '上海市', '长宁区'],
            ['浙江省', '杭州市', '拱墅区'],
          ],
          area_code_list: [
            ['310000000000', '310100000000', '310105000000'],
            ['330000000000', '330100000000', '330105000000'],
          ],
          remark: '备注',
          created_at: '@date()',
          operator: '@cname(3)',
          id: '@id()',
          'limit_type|1': [1, 2],
          'league_id|1': ['0', '@id'],
          league_name: '@cname',
        },
      ],
    });

    let result: ResponseItem = {
      code: 0,
      msg: '成功',
      data: {
        ...data,
        total: data.list.length,
      },
    };
    return res.json(result);
  },
  'POST /jdk/League/simple': (req: Request, res: Response) => {
    const { league_name } = req.body;
    const data = Mock.mock({
      'list|1-30': [
        {
          league_id: '@id()',
          league_name: '@cname(3)',
          phone: '13783636923',
        },
      ],
    });

    let result: ResponseItem = {
      code: 0,
      msg: '成功',
      data: league_name ? data : [],
    };
    return res.json(result);
  },
  'POST /jdk/delivery/Whitelist/getList': (req: Request, res: Response) => {
    const data = Mock.mock({
      'list|1-30': [
        {
          phone: '@phone',
          brand_name: '顺丰同城',
          brand: 'sftc',
          area_name_list: [
            ['上海市', '上海市', '长宁区'],
            ['上海市', '上海市', '徐汇区'],
          ],
          area_code_list: [
            ['310000000000', '310100000000', '310105000000'],
            ['310000000000', '310000000000', '310104000000'],
          ],
          id: '@id()',
          operator: '1',
          remark: 'test',
          created_at: '2022-12-23 15:53:56',
          'use_type|1': [1, 2],
          'league_id|1': ['0', '@id'],
          league_name: '@cname',
        },
      ],
    });

    let result: ResponseItem = {
      code: 0,
      msg: '成功',
      data: {
        ...data,
        total: data.list.length,
      },
    };
    return res.json(result);
  },
  'POST /jdk/delivery/Forbid/getAreaInfoByBrand': (req: Request, res: Response) => {
    let result: ResponseItem = mock({
      code: 0,
      msg: '成功',
      data: {
        'type|1': [3, 0],
        area_list: [
          {
            name: '上海市上海市长宁区',
            code: '330000000000,330100000000,330105000000',
          },
          // {
          //   name: '上海市上海市徐汇区',
          //   code: '310000000000,310000000000,310104000000',
          // },
        ],
      },
    });
    return res.json(result);
  },
  'POST /jdk/delivery/Forbid/remove': (req: Request, res: Response) => responseSuccess(req, res),
  'POST /jdk/delivery/Forbid/create': (req: Request, res: Response) => responseSuccess(req, res),
  'POST /jdk/delivery/Forbid/modify': (req: Request, res: Response) => responseSuccess(req, res),
  'POST /jdk/delivery/Whitelist/create': (req: Request, res: Response) => responseSuccess(req, res),
  'POST /jdk/delivery/Whitelist/modify': (req: Request, res: Response) => responseSuccess(req, res),
  'POST /jdk/delivery/Whitelist/remove': (req: Request, res: Response) => responseSuccess(req, res),
  'POST /jdk/delivery/LeaguePublishAdvance/getInfo': (req: Request, res: Response) => {
    const { league_id } = req.body;
    let result: ResponseItem = mock({
      code: 0,
      msg: '成功',
      data: {
        league_id,
        'source_brand|1': [['all'], ['elm', 'meituan']],
        'advance_delivery|1': [{ sftc: 50, ddks: 10 }],
        created_at: '@now()',
        updated_at: '@now()',
      },
    });
    return res.json(result);
  },
  'POST /jdk/delivery/LeaguePublishAdvance/remove': (req: Request, res: Response) =>
    responseSuccess(req, res),
  'POST /jdk/delivery/LeaguePublishAdvance/setting': (req: Request, res: Response) =>
    responseSuccess(req, res),
};
